# -*- coding:utf-8 -*-
# @FileName  :dhcc_per_shortcut.py
# @Time      :2020/12/15 9:56
# @Author    :Zhoujirong
# @Desc      :个人首页快捷菜单

from biz.cases.base_case import BaseCase
from common.log import Log
from biz.flow.first_page import FirstPageRequest
class TestFirstPagePerShortCut(BaseCase):
    '''添加快捷菜单-检索-去除快捷菜单-检索'''
    data_file_name = 'first_page.yaml'
    @classmethod
    def setUpClass(cls):
        cls.cookie = BaseCase().get_token()

    def test_a_per_edit_shortcut(self):
        '''个人-编辑快捷菜单'''
        root = self.file_data.get('root_per')
        ret = FirstPageRequest.edit_shortcut(root, self.cookie)
        Log.info(ret)
        self.assertIn('!DOCTYPE html', ret)

    def test_b_per_get_user_link_menu(self):
        '''个人-所有可编辑的快捷菜单'''
        root = self.file_data.get('root_per')
        ret = FirstPageRequest.get_user_link_menu(root, self.cookie)
        Log.info(ret)
        self.assertIsNotNone(ret)

    def test_c_per_save_shortcut(self):
        '''个人-保存快捷菜单'''
        menuIds = self.file_data.get('menuIds_per')
        root = self.file_data.get('root_per')
        ret = FirstPageRequest.save_shortcut(menuIds, root, self.cookie)
        Log.info(ret)
        self.assertEqual('00000000', ret.code)
        self.assertEqual('操作成功', ret.msg)

    def test_d_per_get_shortcut_menu(self):
        '''首页快捷功能-个人'''
        check = self.file_data.get('check_id_per')
        root = self.file_data.get('root_per')
        ret = FirstPageRequest.get_shortcut_menu(root, self.cookie)
        Log.info(ret)
        self.assertEqual(str(check), ret[0]['id'])

    def test_e_per_save_shortcut2(self):
        '''个人-保存快捷菜单'''
        menuIds = ''
        root = self.file_data.get('root_per')
        ret = FirstPageRequest.save_shortcut(menuIds, root, self.cookie)
        Log.info(ret)
        self.assertEqual('00000000', ret.code)
        self.assertEqual('操作成功', ret.msg)

    def test_f_per_get_shortcut_menu2(self):
        '''首页快捷功能-个人'''
        check = self.file_data.get('check_id_per')
        root = self.file_data.get('root_per')
        ret = FirstPageRequest.get_shortcut_menu(root, self.cookie)
        Log.info(ret)
        self.assertEqual([],ret)


if __name__ == "__main__":
    pass